"""
登录页面
"""
from selenium.webdriver.common.by import By

from page_objects.base_page import BasePage
from utils.log_util import logger


class LoginPage(BasePage):

    _BASE_URL = "https://litemall.hogwarts.ceshiren.com/#/login"

    __INPUT_USERNAME = (By.NAME, "username")
    __INPUT_PASSWORD = (By.NAME, "password")
    __BTN_LOGIN = (By.CSS_SELECTOR, '.el-button--primary')

    def login(self):
        logger.info("访问登录页面")

        self.do_send_keys("hogwarts", self.__INPUT_USERNAME)
        self.do_send_keys("test12345", self.__INPUT_PASSWORD)

        self.do_find(self.__BTN_LOGIN).click()

        from page_objects.home_page import HomePage
        return HomePage(self.driver)
